SUHUMIZONE = ZONE:New("SuhumiZone")
ZoneCaptureCoalition_Suhumi = ZONE_CAPTURE_COALITION:New(SUHUMIZONE,
SIDE.RED)

ZoneCaptureCoalition_Suhumi:__Guard(1)

ZoneCaptureCoalition_Suhumi:Start(10, 30)
local zoneflag_suhumi = false

-- 开始防卫区域
function ZoneCaptureCoalition_Suhumi:OnEnterGuarded( From, Event, To )
    
    if From ~= To then
        local coalition = self:GetCoalition()
        if coalition == SIDE.RED then
            MessageToAll("敌人占领了苏呼米机场", 10, "Airbase")
            SOUND_INTEL:ToAll()

            CLIENTS_SUHUMI:ForEachClient(function ( client )
                local name = client.ClientName
                USERFLAG:New(name):Set(100) -- disable
            end)

            if RED_BASE_Suhumi:GetFirstAliveGroup() == nil then
                RED_BASE_Suhumi:Spawn()
            end -- 如果红方基地被摧毁了，则新建一个

            if RED_BASE_ATTACK_Suhumi then
                RED_BASE_ATTACK_Suhumi:SpawnScheduleStop()
            end

        elseif coalition == SIDE.BLUE then
            MessageToAll("我们占领了苏呼米机场。请协助防御该机场。", 10, "Airbase") -- 报告蓝方占领机场
            STAGE:Set(2)
            SOUND_AREASECURE:ToAll()

            CLIENTS_SUHUMI:ForEachClient(function ( client )
                local name = client.ClientName
                USERFLAG:New(name):Set(0) -- enable
            end)

            if RED_BASE_ATTACK_Suhumi then
                RED_BASE_ATTACK_Suhumi:SpawnScheduleStart() -- 红方地面部队开始进攻苏呼米    
            end

            zoneflag_suhumi = true -- 更改苏呼米机场flag

            if BLUE_BASE_Suhumi:GetFirstAliveGroup() == nil then -- 生成蓝方基地检查
                BLUE_BASE_Suhumi:Spawn()
            end
        end
    end
end

-- enter empty function
function ZoneCaptureCoalition_Suhumi:OnEnterEmpty()
    if zoneflag_suhumi == false then -- 如果蓝方清空了机场
        MessageToAll("机场威胁已清除，地面部队正在接管机场。", 10, "Airbase")
        BLUE_BASE_Suhumi:Spawn()
    else -- 如果红方清理了机场
        RED_BASE_Suhumi:Spawn()
    end
end


function ZoneCaptureCoalition_Suhumi:OnEnterAttacked(From, Event, To)
    local coalition = self:GetCoalition()
    if coalition == SIDE.BLUE then -- BLUE Coalition is under attack in Zone01
        MessageToAll("苏呼米机场正在被敌方攻击！", 10, "Airbase")
    else
        MessageToAll("我们正在攻击苏呼米机场！", 10, "Airbase")
    end
end

